#include<string>
#include<vector>
#include<array>
#include<unordered_map>
#include<algorithm>
#include<limits>
#include <stack>
#include<iostream>
#include<sstream>
#include<deque>
#include<queue>
#include<set>
#include<unordered_set>
#define MOD 1000000007
class Solution {
public:
    int findSubstringInWraproundString(std::string s) {
        int n = s.size();
        std::vector<int> arr(n,0);
        for (int i=0;i<n;i++)
        {
            arr[i] = s[i]-'a';
        }
        std::array<int ,26>dp;
        dp.fill(0);
        int len = 1;
        dp[arr[0]] = 1;
        for (int i=1;i<n;i++)
        {
        
           
                if (arr[i]==0&&arr[i-1]==25||arr[i-1]+1==arr[i])
                {
                    len++;
                }
                else
                {
                    len=1;
                }
            
            dp[arr[i]] = std::max(dp[arr[i]],len);
        }
        int ans = 0;
        for (int i=0;i<26;i++)
        {
            ans+=dp[i];
        }
        return ans;
    }
};
